Single Select Autocomplete Added to Student Admin#36609
Single Select Autocomplete Added to Student Admin#36609feanil merged 13 commits intoopenedx:masterfrom
Conversation
| """ | ||
|
|
||
|
|
||
| from django.utils.translation import gettext_lazy as _ |
There was a problem hiding this comment.
Could you please clarify why import gettext_lazy is added? I noticed there are no other changes in this file.
There was a problem hiding this comment.
I removed the changes for this and missed this removal. I'll do it right now and update it.
| @@ -0,0 +1,3 @@ | |||
| import pycountry | |||
|
|
|||
| LANGUAGE_CHOICES = sorted({lang.name for lang in pycountry.languages if hasattr(lang, 'alpha_2')}) | |||
There was a problem hiding this comment.
Could you please explain why the condition for alpha_2 was added in this line or what is meant by alpha_2?
There was a problem hiding this comment.
This checks if the language has a 2 letter language code e.g 'en' for english. If so, only then is it kept as I was maintaining uniformity and that is the usual standard.
54cdfa0 to
40b9db8
Compare
|
I have tested this functionality on my system to verify backward compatibility. First, I switched to the Screen.Recording.2025-04-28.at.5.26.32.PM.1.1.mp4 |
common/djangoapps/student/admin.py
Outdated
| return super().get_queryset(request).select_related('user') # lint-amnesty, pylint: disable=no-member, super-with-arguments | ||
|
|
||
|
|
||
| class LanguageAutocomplete(autocomplete.Select2ListView): |
There was a problem hiding this comment.
make sure user is logged in. you can add a decorator here
@method_decorator(login_required, name='dispatch')
There was a problem hiding this comment.
Thank you for the catch. I've added it.
common/djangoapps/student/admin.py
Outdated
| return [] | ||
| return [lang for lang in LANGUAGE_CHOICES if self.q.lower() in lang.lower()] | ||
|
|
||
| class CountryAutocomplete(autocomplete.Select2ListView): |
There was a problem hiding this comment.
Thank you for the catch. I've added it.
|
Sandbox deployment failed 💥 |
1 similar comment
|
Sandbox deployment failed 💥 |
|
Sandbox deployment failed 💥 |
1 similar comment
|
Sandbox deployment failed 💥 |
|
Sandbox deployment failed 💥 |
|
@feanil Please review. |
|
@feanil can you please review this PR. |
29b5cc1 to
7d67d48
Compare
7d67d48 to
2c03480
Compare
2c03480 to
30feea5
Compare
|
Sandbox deployment successful 🚀 |
feanil
left a comment
There was a problem hiding this comment.
This makes sense to me, we'll have to be careful where we add this to but this seems like a simple enough place to put in some helpful auto-completion.
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Student admin interface by adding single-select autocomplete dropdowns for language and country fields, backed by pycountry and django-autocomplete-light.
- Pin and enable django-autocomplete-light across all requirement sets.
- Register DAL apps and define Select2 autocomplete views and inline form for UserProfile.
- Add tests covering the new autocomplete endpoints.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| requirements/edx/testing.txt | Pin django-autocomplete-light for test environments |
| requirements/edx/kernel.in | Pin django-autocomplete-light in kernel requirements |
| requirements/edx/doc.txt | Pin django-autocomplete-light in documentation requirements |
| requirements/edx/development.txt | Pin django-autocomplete-light in development requirements |
| requirements/edx/base.txt | Pin django-autocomplete-light in base requirements |
| openedx/core/djangoapps/site_configuration/admin.py | Remove stray blank lines |
| lms/envs/common.py | Add ‘dal’ and ‘dal_select2’ to INSTALLED_APPS |
| common/djangoapps/student/constants.py | Introduce LANGUAGE_CHOICES from pycountry |
| common/djangoapps/student/admin.py | Implement Language/Country Select2ListView, inline form, and URLs |
| common/djangoapps/student/tests/test_admin_views.py | Add TestUserProfileAutocompleteAdmin and related test cases |
Comments suppressed due to low confidence (3)
common/djangoapps/student/constants.py:1
- [nitpick] Docstring includes a leading
#; consider removing the hash so the text reads cleanly without markup syntax.
"""# Generate a sorted list of unique language names from pycountry """
common/djangoapps/student/tests/test_admin_views.py:555
- The name
reverseis used here but not imported; please addfrom django.urls import reverseat the top of the file.
self.language_url = reverse('admin:language-autocomplete')
common/djangoapps/student/tests/test_admin_views.py:540
TestCaseis not imported; addfrom django.test import TestCase(or import from unittest) to ensure the class definition is valid.
class TestUserProfileAutocompleteAdmin(TestCase):
| # via | ||
| # -r requirements/edx/base.txt | ||
| # django-statici18n | ||
| django-autocomplete-light==3.12.1 |
There was a problem hiding this comment.
[nitpick] The same version of django-autocomplete-light is pinned in multiple requirement files; consider centralizing this pin in base or a constraints file to avoid duplication.
|
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
|
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
|
2U Release Notice: This PR has been deployed to the edX production environment. |
Related Issue
Description
This PR adds the following to the admin panel:
These changes are to improve user experience when using the admin panel for the 'Student' Application.
Screenshots
Navigation Flow: Admin Panel > Users > Add/Edit User
Supporting information
N/A
Testing instructions
musa/admin-revamp-dropdownbranch.pip install -r requirements/dev.txt, orpip install django-autocomplete-lightinside your container.http://local.openedx.io:8000/admin/auth/user/.Deadline
None
Other information
Test Cases